package com.example.demo.message.business;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author liguang03
 * @date 2024/3/13
 */
@Service
public class BusinessProcessDataFactory {

    @Autowired
    private List<AbstractDataProcessBase> dataProcessBases;

    private Map<String, AbstractDataProcessBase> serviceBaseMap;


    @PostConstruct
    public void init() {
        serviceBaseMap = new HashMap<>(dataProcessBases.size());
        for (AbstractDataProcessBase progressServiceBase : dataProcessBases) {
            serviceBaseMap.put(progressServiceBase.getBusiness(), progressServiceBase);
        }
    }


    public AbstractDataProcessBase build(String busiess) {
        return serviceBaseMap.get(busiess);
    }
}
